OpenRoads Designer CONNECT Edition SDK Help

Get terrain points with elevation zero

The terrain is made up of points, triangles, and contours. Each point on a terrain has a different elevation value based on terrain surface. From those points if user wants to find the terrain points having zero elevation value, the below code snippet shows how this can be achieved.

Example


internal void GetTerrainPointsWithElevation0()
        {
            //Get active dgn model
            Bentley.DgnPlatformNET.DgnModel dgnModel = Session.Instance.GetActiveDgnModel();
            //Create connection to dgnModel
            Bentley.CifNET.SDK.ConsensusConnection consensusConnection = new ConsensusConnection(dgnModel);
            //Get active geometric model
            Bentley.CifNET.GeometryModel.SDK.GeometricModel geometricModel = consensusConnection.GetActiveGeometricModel();

            List<DPoint3d> pointList = new List<DPoint3d>();

            //Get all terrains
            foreach (Bentley.CifNET.GeometryModel.SDK.TerrainSurface ts in geometricModel.TerrainSurfaces)
            {
            //Get terrain model
            Bentley.TerrainModelNET.DTM dtm = ts.DTM;
                //Get all points count from terrain model
                int nCount = (int)dtm.VerticesCount;

                for (int nId = 0; nId < nCount; ++nId)
                {
                    //Get point and check Z coordinate of pt to get elevation
                    Bentley.GeometryNET.DPoint3d point = dtm.GetPoint(nId);
                    //Add points into list having zero elevation
                    if (point.Z == 0.0)
                        pointList.Add(point);
                }
            }
        } 

From terrain model get all points. Iterate through all points to get each point elevation, the point's Z coordinate represents the elevation of that point